package 蓝桥真题;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class 杨辉三角形 {
	   static Scanner sc=new Scanner(System.in);
	   final static int N=20000000;
	   static long []a=new long[N];
	   
	   public static void main(String[]args)throws Exception{
		      a[0]=1;a[1]=2;a[2]=1;
		      int n=3,x=sc.nextInt();
		      if(x==1){
		    	  System.out.print(1);
		    	  return;
		      }else if(x==2){
		    	  System.out.print(5);
		    	  return;
		      }
		      while(true){
		    	    for(int i=n/2;i>0;i--){
		    	    	if(n%2==0&&i==n/2)a[i]=2*a[i-1];
		    	    	else a[i]=a[i-1]+a[i];
		    	    	if(a[i]==x){
		    	    		System.out.print(n*(n+1L)/2+i+1);
		    	    		return;
		    	    	}
		    	    }
		    	    if(a[2]>x)break;
		      }
		      n=x;
		      System.out.print(n*(n+1L)/2+n+1);
	   }

}
